﻿using System;
using System.Reflection;
using System.Windows.Forms;

using DreamCube.Foundation.Basic.Utility;

namespace BGN.PlugIn.Client.Tool
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            String assemblyTitle = MyAssembly.GetAssemblyTitle(Assembly.GetEntryAssembly());
            if (MyApp.IsExistApp(assemblyTitle))
            {
                MessageBox.Show("只能运行一个程序实例", "提醒");
            }
            else
            {
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.Run(new MainForm());
            }
        }

        /// <summary>
        /// 未处理的异常
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                MyLog.MakeLog(e.ExceptionObject.ToString());
            }
            catch (Exception)
            { }
        }
    }
}
